// pages/addteam/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    AddTeamName:"",
    AddTeamLeaderName:"",
    AddTeamMark:"",
    userId:"",
  },

  onload: function(e){
    
  },
  //将团队名称传入
  getAddTeamName: function (e) {
    let value = e.detail.value;
    console.log( e.detail.value)
    this.setData({
      AddTeamName: value,
    })
    wx.setStorageSync('AddTeamName', value);
  },
  //将队长名字传入
  getLearderName: function (e) {
    let value = e.detail.value;
    console.log( e.detail.value)
    this.setData({
      AddTeamLeaderName: value,
    })
    wx.setStorageSync('getLearderName', value);
  },
  //讲电话传入
  // getLeaderTelrName: function (e) {
  //   let value = e.detail.value;
  //   console.log( e.detail.value)
  //   // this.setData({
  //   //   AddTeamName: value,
  //   // })
  //   wx.setStorageSync('getLeaderTelrName', value);
  // },
  //备注传入
  Teamreamrk: function (e) {
    let value = e.detail.value;
    // console.log( e.detail.value)
    this.setData({
      AddTeamMark: value,
    })
    wx.setStorageSync('Teamreamrk', value);
  },
  submitMeetInfo: function (e) {
    let userId = wx.getStorageSync("userId");
    console.log(userId);
    this.setData({
      userId: userId,
    })
    var that = this;
    //像后端传值
    wx.request({
      url:'http://172.17.60.141/createGroupServlet', 
      data: {
        user:userId,
        group_name: this.data.AddTeamName,
        leader_name: this.data.AddTeamLeaderName,
        TeamMark: this.data.AddTeamMark,
      },
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      method: 'POST',
      // header: {}, // 设置请求的 header 默认是application/json
      success: function (res) {
          console.log(res.data)
          that.setData({       //this.setData的方法用于把传递过来的id转化成小程序模板语言
          data: res.data    //拿到该商品详情对应的商品id，再调用getProdutInfo方法
        })
      },
      fail: function () {
        // fail
        console.log("false");
      },
      complete: function () {
        // complete
      }
    })
    wx.navigateTo({
      url:'/pages/teamInfo/index',
    })
  },
})